package org.korosoft.rusalad.syncnrun.command;

import org.korosoft.rusalad.syncnrun.messaging.Message;
import org.korosoft.rusalad.syncnrun.messaging.MessageRoute;

import java.util.Collection;
import java.util.UUID;

/**
 * Syncnrun RPC command with messaging support between the client and the server.
 *
 * @author Dmitry Korotkov
 * @since 1.0
 */
public interface MessageDrivenCommand<A extends Answer> extends Command<A> {
    /**
     * Returns message routes accepted my client side. Incoming messages are routed to {@link MessageDrivenCommand#processMessageAtClient(org.korosoft.rusalad.syncnrun.messaging.MessageRoute, org.korosoft.rusalad.syncnrun.messaging.Message)} method.
     * <p/>
     * Message route names should be unique for every specific command instance to ensure correct routing.
     *
     * @return Returns message routes accepted by client side.
     */
    Collection<UUID> getRouteNames();

    /**
     * Method processMessage processes message incoming from remote server.
     *
     * @param route   Incoming message route
     * @param message Incoming message
     */
    public void processMessageAtClient(MessageRoute route, Message message);
}
